﻿using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System.Text;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;

namespace AdminWeb.Areas.Dify.Controllers
{
    public class ChatController : Controller
    {
        private const string token = "app-fcGNne01EhSD5PkVxEm0tzIi";
        public async Task<IActionResult> Index()
        {
            var httpClient = new HttpClient();
            httpClient.BaseAddress = new Uri("http://122.226.108.134:2580/v1");
            httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer "+ token);
            httpClient.DefaultRequestHeaders.Add("Content-Type", "application/json");
            var mssage = new HttpRequestMessage(HttpMethod.Post, "chat-messages");

            var todoItemJson = new StringContent(
                JsonConvert.SerializeObject(new
                {
                    inputs= new { },
                    query= "What are the specs of the iPhone 13 Pro Max?",
                    response_mode = "streaming",
                    conversation_id = "018c7f3d-a672-4de6-bd07-6147e150cff3",
                    user = "abc-123",
     
}),
                Encoding.UTF8,
                Application.Json);
            var resultmsg = await  httpClient.PostAsync("chat-messages", todoItemJson);
            return View();
        }
    }
}
